<?php
/**
 * +----------------------------------------------------------------------
 * | 九月科技-ztuc.cn
 * +----------------------------------------------------------------------
 *                      .::::.
 *                    .::::::::.            | AUTHOR: siyu
 *                    :::::::::::           | EMAIL: ztucke@ztuc.cn
 *                 ..:::::::::::'           | DATETIME: 2020/01/31
 *             '::::::::::::'
 *                .::::::::::
 *           '::::::::::::::..
 *                ..::::::::::::.
 *              ``::::::::::::::::
 *               ::::``:::::::::'        .:::.
 *              ::::'   ':::::'       .::::::::.
 *            .::::'      ::::     .:::::::'::::.
 *           .:::'       :::::  .:::::::::' ':::::.
 *          .::'        :::::.:::::::::'      ':::::.
 *         .::'         ::::::::::::::'         ``::::.
 *     ...:::           ::::::::::::'              ``::.
 *   ```` ':.          ':::::::::'                  ::::..
 *                      '.:::::'                    ':'````..
 * +----------------------------------------------------------------------
 */
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/3/13
 * Time: 20:11
 */
namespace app\store\controller;

use app\core\InitController;
use think\facade\View;
use think\facade\Db;
use app\store\model\Notice;
use app\store\model\User as UserModel;
/**
 * 首页控制器
 * Class Index
 * @package app\controller\index
 */
class Index extends InitController
{ 
     // 聊天
    public function chat()
    {    
         //聊天评论 
        $chatReply = Notice::chatReply();
        View::assign('count', $chatReply['count']);
        return View::fetch('chat',['chatReply' => $chatReply['chatReply']]);
    }
     // 首页
    public function index()
    {  
        UserModel::whereTime('exp_time','<=',time()-60*60*4)->where(['status' => 0])->update(['status' => 1]);//更新解黑状态
        add_user_log('view', '首页');
          return View::fetch('index', ['reading' => self::cars()['reply']]);//首页数据

     
    }
   
          //昵称(汉/英/数)
       public static function cars() {

        $cars_one = explode(',',get_config('set_code.cars_one'));

        $cars_two = explode(',',__('cars_two'));

        $cars_three = explode('|',get_config('set_code.cars_three'));
        
        $cars_1 = $cars_one[rand(0, count($cars_one) - 1)];
        $cars_2 = $cars_two[rand(0, count($cars_two) - 1)];
        $cars_3 = $cars_three[rand(0, count($cars_three) - 1)];
        $cars_s = $cars_1 . $cars_2 . '，' . $cars_3;
        $cars_sb = $cars_1 . $cars_2;
        return [
            'reply' => $cars_s,
            'car' => $cars_sb,
        ];

     }
}
